home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / BooleanArrayOption.java < prev    next >
Text File  |  1998-09-08  |  2KB  |  94 lines

  1. package com.symantec.itools.frameworks.application.commandline;
  2.  
  3.  
  4. /**
  5.  * BooleanArrayOption is an abstract base class for all boolean
  6.  * array command line arguments.
  7.  * @author Symantec Internet Tools Division
  8.  * @version 1.0
  9.  * @since VCafe 3.0
  10.  */
  11.  
  12. public abstract class BooleanArrayOption 
  13.     extends ArrayOption
  14. {
  15.     public BooleanArrayOption()
  16.     {
  17.     }
  18.  
  19.     public BooleanArrayOption(String[] flags)
  20.     {
  21.         super(flags);        
  22.     }
  23.  
  24.     public BooleanArrayOption(String[] flags, int count)
  25.     {
  26.         super(flags, count);
  27.     }
  28.  
  29.     /**
  30.      * @param args TODO
  31.      * @param startIndex TODO
  32.      * @exception com.symantec.itools.frameworks.application.commandline.MissingArgumentsException
  33.      * @since VCafe 3.0
  34.      */
  35.     /*
  36.         args[ start_index ] will be the flag.
  37.         args[ start_index + 1 ] should be the first integer value
  38.     */
  39.     protected boolean[] getBooleanArray(String[] args, int startIndex)
  40.         throws MissingArgumentsException
  41.     {
  42.         boolean[] array;
  43.         
  44.         array = new boolean[count];
  45.         
  46.         try
  47.         {
  48.             for(int i = 0; i < count; i++)
  49.             {
  50.                 array[i] = Boolean.valueOf(args[startIndex + i + 1]).booleanValue();
  51.             }
  52.         }
  53.         catch(ArrayIndexOutOfBoundsException ex)
  54.         {
  55.             throw new MissingArgumentsException(args[startIndex]);
  56.         }
  57.         
  58.         return (array);
  59.     }
  60.  
  61.     /**
  62.      * @param args TODO
  63.      * @param startIndex TODO
  64.      * @param count TODO
  65.      * @exception com.symantec.itools.frameworks.application.commandline.MissingArgumentsException
  66.      * @since VCafe 3.0
  67.      */
  68.     /*
  69.         args[ start_index ] will be the flag.
  70.         args[ start_index + 1 ] should be the first integer value
  71.     */
  72.     protected boolean[] getBooleanArray(String[] args, int startIndex, int count)
  73.         throws MissingArgumentsException
  74.     {
  75.         boolean[] array;
  76.         
  77.         this.count = count;
  78.         array   = new boolean[count];
  79.         
  80.         try
  81.         {
  82.             for(int i = 0; i < count; i++)
  83.             {
  84.                 array[i] = Boolean.valueOf(args[startIndex + i + 1]).booleanValue();
  85.             }
  86.         }
  87.         catch(ArrayIndexOutOfBoundsException ex)
  88.         {
  89.             throw new MissingArgumentsException(args[startIndex]);
  90.         }
  91.         
  92.         return (array);
  93.     }
  94. }